@extends('layouts.app')
@section('title',$user->name.'的个人空间')

@section('content')
    <div class="row">
        <div class="col-md-3 mb-2">
            <div class="card">
                <img alt="{{$user->name}}" src="{{$user->avatar}}" class="img-thumbnail border-0 rounded"/>
                <div class="card-body">
                    <h5>个人简介</h5>
                    <p class="text-muted">{{$user->introduction}}</p>
                    <hr>
                    <h5>注册于</h5>
                    <p class="text-muted">{{$user->created_at->diffForHumans()}}</p>
                </div>
            </div>
        </div>
        <div class="col-md-9">
            <div class="card mb-2">
              <div class="card-body">
                  <h1 class="p-2">{{$user->name}} <small>{{$user->email}}</small></h1>
              </div>
            </div>
            <div class="card">
                <div class="card-body">
                    <ul class="nav nav-tabs">
                        <li class="nav-item">
                            <a class="nav-link {{active_class(if_query('tab',null))}}" aria-current="page"
                               href="{{route('users.show',$user->id)}}">TA的帖子</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{active_class(if_query('tab','replies'))}}"
                               href="{{route('users.show',[$user->id,'tab'=>'replies'])}}">TA的回复</a>
                        </li>
                    </ul>
                    @if(if_query('tab','replies'))
                        @include('users._replies',['replies'=>$user->replies()->with('user')->recent()->paginate(5)])
                    @else
                        @include('users._topics',['topics'=>$user->topics()->recent()->paginate(5)])
                    @endif
                </div>
            </div>
        </div>
    </div>
@stop

